<?php
namespace com\mvc\controller;
class Controller{
	public function __construct(){
		
	}
	public function router(){
		try{
			$request = new \com\mvc\core\Request();
			$path = $request->path();
			$size = count($path);
			if ($path && $size>0 && strtoupper($path[0])!=INDEX_PHP){
				$classname = "\\com\\mvc\\model\\".ucfirst($path[0]).MODEL;
			}else{
				$classname = "\\com\\mvc\\model\\".INDEX.MODEL;
				if ($size>0){
					$path = array();
				}
				$path[]=INDEX;
			}
			if (class_exists($classname)){
				$obj = new $classname;
			}else{
				$obj = new \com\mvc\model\GenericModel();
				//throw new \Exception("", -1, null);
			}
			 $obj->model($path[0]);
			//call_user_func_array(array($obj, "router"), $path);
			
			//Metemos aquí la llamada al binding o el modelo
			
			/*$conn = \com\mvc\orm\DB::getInstance();
			$conn = \com\mvc\orm\DB::getInstance();
			$db = $conn->getDB();
			$where = $conn->addWhere(array(new \com\mvc\orm\dao\GenericObjectDB("columna","expresion","tipo","operacion")));
			
			$this->render(PATH_VIEWS.ucfirst($path[0]).VIEW.EXTENSION);*/
			
			
			
		}catch (\Exception $e){
			$this->render(PATH_VIEWS.ERROR.VIEW.EXTENSION);
		}
	}
}
?>